home *** CD-ROM | disk | FTP | other *** search
- /* datedemo.c is just a short demo program which uses most of the
- functions contained in the dates.c library. By using the listing
- of this program you should be able to incorporate the dates routines
- in your programs.
- To compile datedemo.c with the dates library type the following
- from the comand line:
- tcc -ms datedemo.c dates.obj
- Have fun and enjoy! Gerry Rohr
- */
- #include "dates.h"
- #include <stdio.h>
-
- void main(void)
- {
- DATE in_date;
- JULDATE j_date;
- int i;
-
- in_date = 19890310;
- printf("-----Start of Test Run-----\n");
- printf("%ld is !%s!\n",in_date,dtoa(in_date));
- printf("Month of %ld is %d\n",in_date,month(in_date));
- printf("Day of %ld is %d\n",in_date,day(in_date));
- printf("Year of %ld is %d\n",in_date,year(in_date,1));
- printf("Year of %ld is %d\n",in_date,year(in_date,0));
- greg_to_jul(in_date,&j_date);
- printf("Julian date is %d/%d or %s\n",j_date.yr,j_date.day,jul_dt_st(&j_date));
- in_date = jul_to_greg(&j_date);
- printf("Converted to greg is %ld\n",in_date);
- printf("Converted back is !%s!\n",dtoa(in_date));
- next_day(&in_date);
- printf("Next day is !%s!\n",dtoa(in_date));
- printf("Full date string is %s\n",full_date_st(in_date));
- prev_day(&in_date);
- printf("Prev day is !%s!\n",dtoa(in_date));
- printf("Month of %ld is %s\n",in_date,month_name(month(in_date)));
- for(i=0;i<6;i++)
- {
- printf("Day of %ld is %s\n",in_date,day_name(in_date));
- next_day(&in_date);
- }
- printf("Valid_date returned %d\n",valid_date(in_date));
- in_date = NO_DATE;
- printf("NO_DATE is !%s!\n",dtoa(in_date));
- in_date = 19890155L;
- printf("Valid_date of %ld is %d\n",in_date,valid_date(in_date));
- in_date = 18981315L;
- printf("Valid_date of %ld is %d\n",in_date,valid_date(in_date));
- printf("-----End of Test Run-----");
- } /* end of main */
-